package cn.hdmis.service.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import cn.hdmis.dao.ClassRoomDao;
import cn.hdmis.entity.ClassRoom;
import cn.hdmis.security.service.impl.BaseServiceImpl;
import cn.hdmis.service.ClassRoomService;
public class ClassRoomServiceImpl extends BaseServiceImpl<ClassRoom> implements ClassRoomService {

	private ClassRoomDao classRoomDao;
	
	public void setClassRoomDao(ClassRoomDao classRoomDao) {
		this.classRoomDao = classRoomDao;
	}

	public ClassRoomDao getClassRoomDao() {
		return classRoomDao;
	}
	
	@Override
	public void addClassRoom(ClassRoom classRoom) throws Exception {
		try {
			classRoomDao.save(classRoom);
		} catch (Exception e) {
			throw e;
		}
		 
	}
	
	@Override
	public List<ClassRoom> getClassRoom() {
		return classRoomDao.findAllEntity();
	}
	
	@Override
	public Map<String, String> getClassRoomKeyMap() {
		List<ClassRoom> list =  classRoomDao.findAllEntity();
		Map<String,String> map = new HashMap<String, String>();
		if(list!=null&&list.size()>0){
			Iterator<ClassRoom> itor = list.iterator();
			while(itor.hasNext()){
				ClassRoom cr = (ClassRoom) itor.next();
				map.put(String.valueOf(cr.getId()), cr.getName());
			}
		}
		return map;
	}	
	@Override
	public String getTestDrw(String name){
		return "this name:"+name;
	}
}
